Imports System.Data.SqlClient
Imports Microsoft.ApplicationBlocks.Data.SqlHelper
Public Class CiudadesProvinciasPaises

    Public Function ObtenerCiuPro(ByVal Cod As Integer, Optional ByVal Tip As String = Nothing)
        'Por defecto busca las Provincias de los Paises, si se quiere las Cuidades o Localidares de la Provincia: Tip = "CiuLoc"
        Dim DS As New DataSet
        DS = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(My.Settings.MiCadena, _
        CommandType.StoredProcedure, "CiuProObtener", New SqlParameter("@Cod", Cod), New SqlParameter("@Tip", Tip))
        Return DS
    End Function

    Public Function ObtenerCiuProPai(Optional ByVal Nom As String = "", Optional ByVal Tip As String = "")
        'Por defecto busca los Paises, si se quiere provincias enviar Tip = "Pro" o CiudadLocalidad Tip = "CiuLoc"

        Dim DS As New DataSet
        DS = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(My.Settings.MiCadena, _
        CommandType.StoredProcedure, "CiuProPaiObtener", New SqlParameter("@Nom", Nom), _
        New SqlParameter("@Tip", Tip))
        Return DS
    End Function

    Public Function GenerarCuiProPai(ByVal Nom As String, Optional ByVal CodCPP As Integer = 0, Optional ByVal CodPos As Integer = 0, _
    Optional ByVal CodAre As Integer = 0, Optional ByVal Obs As String = "", Optional ByVal Tip As String = "")
        Dim DS As New DataSet
        'Para agregar Cuidades y Localidades (Tip = "CuiLoc"), para agregar Paises (Tip = "Pai") y Provincias (Tip = "Pro") 
        DS = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(My.Settings.MiCadena, CommandType.StoredProcedure, _
        "CiuProPaiGenerar", New SqlParameter("@Nom", Nom), New SqlParameter("@CodCPP", CodCPP), New SqlParameter("@CodPos", CodPos), _
        New SqlParameter("@CodAre", CodAre), New SqlParameter("@Obs", Obs), New SqlParameter("@Tip", Tip))
        Return DS
    End Function

    Public Function ModificarCuiProPai(ByVal Nom As String, Optional ByVal Tip As String = Nothing)
        Dim DS As New DataSet
        REM Por defecto agrega las Cuidades y Localidades, para buscar Paises (Tip="Pa") y Provincias (Tip="Pr") 
        DS = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(My.Settings.MiCadena, CommandType.StoredProcedure, _
        "CiuProPaiModificar", New SqlParameter("@Nom", Nom), New SqlParameter("@Tip", Tip))
        Return DS
    End Function

    Public Function EliminarCiuProPai(ByVal CodCPP As Integer, Optional ByVal Tip As String = Nothing)
        Dim DS As New DataSet
        DS = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(My.Settings.MiCadena, CommandType.StoredProcedure, _
        "CiuProPaiEliminar", New SqlParameter("@CodCPP", CodCPP), New SqlParameter("@Tip", Tip))
        Return DS
    End Function

End Class
